package com.roc.web.action.terminal;

import java.util.ArrayList;
import java.util.List;

import com.roc.page.BaseSearchCondition;
import com.roc.page.WhereHQLFieldBean;
import com.roc.util.Constance;

public class TermianlAllotRecallSearchCondition extends BaseSearchCondition{
	private String orgCode; //机构
	private Long agentId; //代理商
	private String posBrand; //品牌
	private String posType;  //机型
	private String posName; //POS名称
	private String serialNum;//终端序列号
	private String isUsed;
	private Object[] obj;
	@Override
	protected List<WhereHQLFieldBean> getWhereHQLFieldBeanList() {
        List<WhereHQLFieldBean> filedBeanList = new ArrayList<WhereHQLFieldBean>();
        
        if (Constance.isNotEmpty(orgCode)) {
			filedBeanList.add(new WhereHQLFieldBean("a.org_code", orgCode, "=", false));
		}
        if(agentId != null){
			filedBeanList.add(new WhereHQLFieldBean("b.agent_Id", agentId, "=", false));
		}

        if(Constance.isNotEmpty(isUsed)&&!"99".equals(isUsed)){
			filedBeanList.add(new WhereHQLFieldBean("b.is_used", isUsed, "=", false));
		}
        if (Constance.isNotEmpty(serialNum)) {
			filedBeanList.add(new WhereHQLFieldBean("b.SERIAL_NUM", serialNum, "=", false));
		}
		if (Constance.isNotEmpty(posBrand)) {
			filedBeanList.add(new WhereHQLFieldBean("a.pos_Brand", posBrand, "=", false));
		}
		if (Constance.isNotEmpty(posType)) {
			filedBeanList.add(new WhereHQLFieldBean("a.pos_Type", posType, "=", false));
		}
		if (Constance.isNotEmpty(posName)) {
			filedBeanList.add(new WhereHQLFieldBean("a.pos_Name", posName, "=", false));
		}
		return filedBeanList;
	}

	@Override
	protected String getRowCountHQL() {
		StringBuffer sb=new StringBuffer();
		sb.append(" select count(*)  from yj_pos_info a, yj_pos_agent b,(SELECT * FROM t_operators s WHERE s.role_type<>'15') v ");
		sb.append(" where a.is_bind='N' ");
		sb.append(" and a.SERIAL_NUM = b.SERIAL_NUM ");
		sb.append(" and b.agent_Id = v.id ");
		return sb.toString();
	}

	@Override
	protected String getSearchHQL() {
		StringBuffer sb=new StringBuffer();
		sb.append(" SELECT a.serial_num,a.pos_brand,a.pos_type,a.pos_name,a.org_code,a.is_bind,b.agent_id,v.real_name,b.is_used,b.dt_create,b.dt_lastmod,b.remark from yj_pos_info a, yj_pos_agent b,(SELECT * FROM t_operators s WHERE s.role_type<>'15') v ");
		sb.append(" where a.is_bind='N' ");
		sb.append(" and a.SERIAL_NUM = b.SERIAL_NUM ");
		sb.append(" and b.agent_Id = v.id ");		
		return sb.toString();
	}

	@Override
	protected String getOrderPartOfHQL() {
		return " order by a.dt_create desc ";
	}
	public String getOrgCode() {
		return orgCode;
	}

	public void setOrgCode(String orgCode) {
		this.orgCode = orgCode;
	}

	public Long getAgentId() {
		return agentId;
	}

	public void setAgentId(Long agentId) {
		this.agentId = agentId;
	}

	public String getPosBrand() {
		return posBrand;
	}

	public void setPosBrand(String posBrand) {
		this.posBrand = posBrand;
	}

	public String getPosType() {
		return posType;
	}

	public void setPosType(String posType) {
		this.posType = posType;
	}

	public String getPosName() {
		return posName;
	}

	public void setPosName(String posName) {
		this.posName = posName;
	}

	public Object[] getObj() {
		return obj;
	}

	public void setObj(Object[] obj) {
		this.obj = obj;
	}

	public String getSerialNum() {
		return serialNum;
	}

	public void setSerialNum(String serialNum) {
		this.serialNum = serialNum;
	}

	public String getIsUsed() {
		return isUsed;
	}

	public void setIsUsed(String isUsed) {
		this.isUsed = isUsed;
	}
	
}
